#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	int N, M, i, j, c, sum = 0;
	scanf("%d %d", &N, &M);
	int a[N][M];
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < M; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}

	for (i = 0; i < N; i++)
	{
		for (j = 0; j < M; j++)
		{
			if (a[i][j] == 1)
			{
				sum++;
			}
		}
	}
	c = sum * 2 + 2;
	printf("%d", c);
	return 0;
}